package com.extension.company.presenter.home;

import com.extension.company.common.mvp.BasePresenter;
import com.extension.company.contract.home.OnlinePaySuccessContract;
import com.extension.company.model.entity.RetailGoosListBean;
import com.extension.company.model.home.OnlinePaySuccessModel;

import java.util.List;

/**
 * 作者:zwk
 * 联系方式：497981239@qq.com
 * 时间：on 2019/8/7 08:33
 * 功能：在线支付成功的presenter
 */
public class OnlinePaySuccessActivityPresenter extends BasePresenter<OnlinePaySuccessContract.Model, OnlinePaySuccessContract.View> {
	@Override
	public OnlinePaySuccessContract.Model createModel() {
		return new OnlinePaySuccessModel();
	}

	@Override
	protected void onViewDestroy() {

	}

	/**
	 * 支付成功后，订单的确认
	 *
	 * @param orderId 订单id
	 */
	public void commitOrder(String orderId) {
		model.commitOrder(orderId, new OnlinePaySuccessContract.OrderCommitM2P() {
			@Override
			public void m2p(double totalPrice) {
				if (null != getView()) {
					getView().commitOrderSuccess(totalPrice);
				}
			}
		});
	}

	/**
	 * 获取支付完成后，分销商品的列表
	 */
	public void retaiGoodslList() {
		model.retailGoodsList(new OnlinePaySuccessContract.retailListM2P() {
			@Override
			public void m2p(List<RetailGoosListBean.DataBean> retailList) {
				if (null != getView()) {
					getView().retailListSuccess(retailList);
				}
			}
		});
	}
}
